const express = require("express");

const router = express.Router();
const tagSevr = require("../../services/Tag");
const { asyncHandle } = require("../getSendResult");
//分页获取列表
router.get(
  "/",
  asyncHandle(async (req, res) => {
    const search = req.query.search;
    return await tagSevr.findTags(search);
  })
);

//获取单个
router.get("/:id", asyncHandle(async (req,res)=>{
    return await tagSevr.findTagById(req.params.id)
}));

//新增一个
router.post("/", asyncHandle(async (req,res)=>{
    return await tagSevr.addTag(req.body)
}));

//修改
router.put("/:id", asyncHandle(async (req,res)=>{
    return await tagSevr.updateTag(req.params.id,req.body)
}));

//删除
router.delete("/:id", asyncHandle(async (req,res)=>{
    return await tagSevr.deleteTag(req.params.id)
}));

module.exports = router;
